﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;

namespace AnyOffice.general.system.attend
{
    public partial class duty_new : ModulePage 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page.IsPostBack)
            {
                AttendConfigDao dao = new AttendConfigDao();
                AttendConfigData data = new AttendConfigData();
                data.DutyName = this.txtDutyName.Value;
                if (this.txtDutyTime1.Value != string.Empty)
                {
                    data.DutyTime1 = Convert.ToDateTime(DateTime.Now.ToString("d") + " " + this.txtDutyTime1.Value).ToString("HH:mm:ss");
                }
                if (this.txtDutyTime2.Value != string.Empty)
                {
                    data.DutyTime2 = Convert.ToDateTime(DateTime.Now.ToString("d") + " " + this.txtDutyTime2.Value).ToString("HH:mm:ss");
                }
                if (this.txtDutyTime3.Value != string.Empty)
                {
                    data.DutyTime3 = Convert.ToDateTime(DateTime.Now.ToString("d") + " " + this.txtDutyTime3.Value).ToString("HH:mm:ss");
                }
                if (this.txtDutyTime4.Value != string.Empty)
                {
                    data.DutyTime4 = Convert.ToDateTime(DateTime.Now.ToString("d") + " " + this.txtDutyTime4.Value).ToString("HH:mm:ss");
                }
                if (this.txtDutyTime5.Value != string.Empty)
                {
                    data.DutyTime5 = Convert.ToDateTime(DateTime.Now.ToString("d") + " " + this.txtDutyTime5.Value).ToString("HH:mm:ss");
                }
                if (this.txtDutyTime6.Value != string.Empty)
                {
                    data.DutyTime6 = Convert.ToDateTime(DateTime.Now.ToString("d") + " " + this.txtDutyTime6.Value).ToString("HH:mm:ss");
                }
                data.DutyType1 = Convert.ToInt32(this.sltDutyType1.Value);
                data.DutyType2 = Convert.ToInt32(this.sltDutyType2.Value);
                data.DutyType3 = Convert.ToInt32(this.sltDutyType3.Value);
                data.DutyType4 = Convert.ToInt32(this.sltDutyType4.Value);
                data.DutyType5 = Convert.ToInt32(this.sltDutyType5.Value);
                data.DutyType6 = Convert.ToInt32(this.sltDutyType6.Value);
                string str = string.Empty;
                foreach (ListItem item in this.cblGeneral.Items)
                {
                    if (item.Selected)
                    {
                        str = str + item.Value + ",";
                    }
                }
                if (str != string.Empty)
                {
                    data.General = str;
                }
                dao.Insert(base.Conn, data);
                base.CloseConn();
                Response.Redirect("duty.aspx");
            }
        } 

    }
}
